<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>

<%@page import="java.util.List"%>
<%@page import="com.bls.sms.wrapper.Subject"%>

<%
            int size = 0;
            List<Subject> list = null;
            if (request.getAttribute("list") != null) {
                list = (List<Subject>) request.getAttribute("list");
                size = list.size();
            }
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>BLS - School Management System</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<script type="text/javascript">
		function getSubjectDetails(form, subjectId) {
			form.id.value = subjectId;
			form.action.value = "getSubjectDetails";
			form.submit();
		}
		function deleteSubject(subjectId) {
			form.id.value = subjectId;
			form.action.value = "deleteSubject";
			form.submit();
		}
		</script>
	</head>
	<body>
		<p align="center">
			<b> List Of Classes</b>
			</p>
		<html:form action="/subject">
		 <html:hidden property="action"/>
		 <html:hidden property="id"/>
			<table border="1">
			 <thead>
			   <th>Subject Name</th>
			   <th>Action</th>
			 </thead>
			 <tbody>
			<%
			Subject subject = null;
			for (int i = 0; i < size; i++) {
				subject = (Subject) list.get(i);
			%>
			<tr>
			 <td><%= subject.getName() %></td>
			 <td>
			  <input type="button" value="Update" onclick="getSubjectDetails(this.form, <%= subject.getId() %>)">
			  <input type="button" value="Delete" onclick="deleteSubject(this.form, <%= subject.getId() %>)">
			 </td>
			</tr>
			<%}%>
			</tbody>
			</table>
			</html:form>
	</body>
</html>
